<?php
/**
 * AgileOne - Power to Agile Development
 *
 * LICENSE
 *
 * All AgileOne source files are subject to GPL V3 license:
 * 1) You may use the Software for free and non-commercial use
 * 2) You may modify or propagate the source code of the Software
 * 3) Please purchase commercial license for support and consultation
 * For more license infomation, please read the file License.txt.
 *
 * @copyright  Copyright (c) 2010 AgileOne Team (http://code.google.com/p/agileone/)
 * @license    GNU General Public License V3 (http://www.gnu.org/licenses)
 * @version    2009-3-5 1.0
 * @author     DengQiang (http://www.51testing.com/?uid/275266)
 */

class Admin_MailController extends Zend_Controller_Action {

	/**
	 * Initialize the controller for common usage
	 */
    public function init() {
    	$this->view = Zend_Registry::get('view');
    	$this->translate = Zend_Registry::get('Zend_Translate');
    	$this->db = Zend_Db_Table::getDefaultAdapter();
    	$this->_helper->layout->disableLayout();
    }
    
    public function indexAction() {
    	$this->_helper->layout->enableLayout();
        echo $this->view->render('Mail.phtml');
    }
    
    public function setmailAction() {
        $file = new File();
        $data = array(
            'mail.method' => $_POST['method'],
            'mail.sender' => $_POST['sender'],
            'mail.signature' => $_POST['signature'],
            'smtp.server' => $_POST['smtpserver'],
            'smtp.port' => $_POST['smtpport'],
            'smtp.username' => $_POST['smtpusername'],
            'smtp.password' => $_POST['smtppassword']
        );
        $state = $file->updateConfig($data, 'Common/Config/Global.conf');
        echo $state;
    }
    
    public function testmailAction() {
        $common = new Common();
        $state = $common->sendMail($_POST['recipient'], 'Test Mail From AgileOne', Common::replaceAmpStrip($_POST['content']));
        echo $state;
    }
}
?>